package com.service.business.utils;

import cn.hutool.core.util.ReUtil;

public class MemberAccountUtil {

    public static String getUserAccountSuffix(String userAccount) {
        if (isEmail(userAccount)) {
            return userAccount.length() > 6 ? userAccount.substring(0, 6) : userAccount;
        } else {
            return userAccount.length() > 6 ? userAccount.substring(userAccount.length() - 6) : userAccount;
        }
    }


    public static boolean isEmail(String email) {
        String regEx1 = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
        return ReUtil.isMatch(regEx1, email);
    }


}
